# -*- coding: utf-8 -*-


import openpyxl

excel_1 = openpyxl.load_workbook('office.xlsx')      # 可以当作字典索引，键为表名，值为工作表
excel_2 = openpyxl.load_workbook('2020年测试名单.xlsx')

excel_3 = openpyxl.load_workbook('/Volumes/mac数据扩展盘/杂七杂八/2020年测试名单.xlsx')

print(type(excel_1))
print(type(excel_2))

sheet_names = excel_2.sheetnames   # 返回一个工作簿的所有表的名称，为列表

print(sheet_names)

sheet_1 = excel_2["环境生态与生物工程学院"]   # 以表名为索引值，取得一张工作表，

print(type(sheet_1))


column = sheet_1["A"]   # 返回A这一列所有的单元格组成的元组

print(type(column))

row = sheet_1[3]  # 取第三行

print(type(row))

a1 = column[0]  # 取A0单元格



print(a1)
print(a1.value)

_3c = row[2]  # 取C3单元格
_3d = row[3]

print(type(_3c))
print(type(_3d))

print(_3c.value)  # 取C3单元格的值
print(_3d.value)


def get_d1d8(sheet:openpyxl.worksheet.worksheet.Worksheet):
    d = sheet['d']
    # value = []
    # for i in d[0: 8]:
    #     value.append(i.value)

    x = lambda i: i.value

    y = [x(i) for i in d[0: 8]]

    return y




def get_column_values(param: tuple):
    values = []
    for i in param:
        values.append(i.value)
    return values



if __name__ == '__main__':
    print("-------")
    # print(type(sheet_1))
    # print(get_column_values(column))
    # for i in get_column_values(column):
    #     print(i)

    print(get_d1d8(sheet_1))